package 面试.美团;

import java.util.ArrayList;
import java.util.Scanner;
import java.util.SortedMap;
import java.util.TreeMap;
import java.util.concurrent.ConcurrentHashMap;

/**
 * @author : K k
 * @date : 14:01 2020/9/13
 */
public class 美团2 {
    public static int buy(int n,int m,int[] nums,int k){

        int i=0;
        int res=0;
        for(i=0;i<n;i++){
            if(nums[i]>=k){
                int j;
                //计算连续排列里，有多少个a不低于k
                for(j=i;j < n && nums[j]>=k;j++);
                j = j-i-m+1;//共可以买j个
                if(j>0){res+=j;}
                i+=j+m-1;
            }
        }
        return res;
    }
    public static void main(String[] args) {
        Scanner reader = new Scanner(System.in);
        System.out.println("Please input n,m,k");
        int n = reader.nextInt();  //多少种商品
        int m = reader.nextInt();  //需要m个
        int k = reader.nextInt();  //该商品的特值需要大于k
        int[] cm = new int[n];  //商品数组 元素记录的是特值
        System.out.println("Please input a");
        for(int i = 0;i<n;i++){
            cm[i] = reader.nextInt();
        }
        System.out.println(buy(n,m,cm,k));
    }
}
